#include "KEY.h"
#include "systick.h"

void Key_Init(void)
{
    rcu_periph_clock_enable(RCU_GPIOC);
    gpio_mode_set(GPIOC,GPIO_MODE_INPUT,GPIO_PUPD_PULLUP,BITS(0,3));
}




uint8_t Key_Scan(void)
{
    static  uint8_t last_status=1;
    if((KEY1==RESET||KEY2==RESET||KEY3==RESET||KEY4==RESET) && last_status==1)
    {   //down
        delay_1ms(20);
        last_status=0;
        if(KEY1==RESET) return KEY1_Press;
        if(KEY2==RESET) return KEY2_Press;
        if(KEY3==RESET) return KEY3_Press;
        if(KEY4==RESET) return KEY4_Press;

    }else if(KEY1==SET && KEY2==SET && KEY3==SET && KEY4==SET && last_status==0){
        //up
        last_status=1;

    }
    return 0;

}